/**=========================================================
	DESKTOP OBJECT
==========================================================*/
var Desktop = {
	/**
	 *	Adds a new object prototype
	 *
	 *	@param (String) name The name of the prototype
	 *	@param (Object) prototype The prototype object to add
	 *	@param (Object) parent The prototype object that this will extend
	 *	@return (Object) the prototype that was added
	 */
	addPrototype: function (name, prototype, parent) {
		// assign the prototype's type
		prototype.type = name.toLowerCase();

		// add the prototype to the list
		return this.global.isString(name) ? (this.prototypes[name.toLowerCase()] = this.global.extend(parent || this.global, prototype)) : this;
	},
	DOM: [],
	/**
	 *	Adds a new object prototype
	 *
	 *	@param (String) name The name of the prototype
	 *	@return (Object) The prototype
	 */
	getPrototype: function (name) {
		return this.prototypes[name.toLowerCase()];
	},
	global: {
		/**
		 *	Appends this element to an element
		 *
		 *	@param (Object) object The element controller that this will be appended to
		 *	@return (Object) The element that was appended
		 */
		appendTo: function (object) {
			// if that the objects are controlling elements
			if (this.el && object.el) {
				// append this element to the object's element
				element.el.appendChild(this.el);
			}

			// push the element onto the DOM
			(object.DOM ? object.DOM : object.children).push(this);

			return this;
		},
		/**
		 *	Creates an object
		 *
		 *	@param (String) type The type of object to create
		 *	@return (Object) The created object
		 */
		create: function (type) {
			// get the prototype
			var prototype = Desktop.getPrototype(type);

			// assign the parent
			prototype.parent = this;

			// see if the prototype needs to create an element
			if (prototype.hasOwnProperty('el')) {
				// create the element
				prototype.el = document.createElement(type);

				// assign this as the controller of the element
				prototype.el.controller = this;
			}

			// assign the prototype to the object
			Desktop.Object.prototype = prototype;

			// create the object
			return new Desktop.Object();
		},
		/**
		 *	Extends a superclass to a subclass
		 *
		 *	@param (Object)  superclass  The object to extend
		 *	@param (Object)  subclass  The object being extended, defaults to the object calling the function
		 *	@return (Object)  The extended object
		 */
		extend: function (superclass, subclass) {
			var property;

			// Get the correct subclass
			subclass = subclass || this;

			// If parameters, extend
			if (superclass) {

				// Extend the object
				for (property in superclass) {
					// If the property is an object, extend the object
					if (this.isObject(superclass[property])) {
						this.extend(superclass[property], this.isObject(subclass[property]) ? subclass[property] : {});
					}
					// If the property is an array, clone the array
					else if (this.isArray(superclass[property])) {
						this.extend(superclass[property], this.isArray(subclass[property]) ? subclass[property] : []);
					}
					// If the subclass does not have the property, extend it to the subclass
					else {
						if (!subclass.hasOwnProperty(property)) {
							subclass[property] = superclass[property];
						}
					}
				}
			}
			return subclass;
		},

		/**
		 *	Returns whether or not an object is an Array
		 *
		 *	@param (Object) object The object to check, defaults to the object calling the function
		 *	@return (Boolean) If the object is an Array
		 */
		isArray: function (object) {
			return Object.prototype.toString.call(object || this) === '[object Array]';
		},

		/**
		 *	Returns whether or not an object is an Function
		 *
		 *	@param (Object) object The object to check, defaults to the object calling the function
		 *	@return (Boolean) If the object is an Function
		 */
		isFunction: function (object) {
			return Object.prototype.toString.call(object || this) === '[object Function]';
		},

		/**
		 *	Returns whether or not an object is an Object
		 *
		 *	@param (Object) object The object to check, defaults to the object calling the function
		 *	@return (Boolean) If the object is an Object
		 */
		isObject: function (object) {
			return Object.prototype.toString.call(object || this) === '[object Object]';
		},

		/**
		 *	Returns whether or not an object is an Function
		 *
		 *	@param (Object) object The object to check, defaults to the object calling the function
		 *	@return (Boolean) If the object is an Function
		 */
		isString: function (object) {
			return Object.prototype.toString.call(object || this) === '[object String]';
		}
	},
	prototypes: {},
	Object: new Function()
};

Desktop.global.extend(Desktop.global, Desktop);

/**=========================================================
	DESKTOP OBJECT PROTOTYPES
==========================================================*/
Desktop.addPrototype('Element', {
	/**
	 *	Appends a element to this element
	 *
	 *	@param (Object) element The element that will be appended to the current element
	 *	@return (Object) The element that was appended to
	 */
	append: function (element) {

	},
	children: [],
	el: null,
	remove: function (element) {

	},
	render: function () {
		this.el.controller = this;
		this.super.append(this);
	},
	padding: function (top, right, bottom, left) {
		if (this.isObject(top)) {

		}
	},
	style: {},
});